package com.example.demo.controller;


import com.example.demo.pojo.Staff;
import com.example.demo.service.StaffService;
import com.example.demo.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.demo.pojo.Staff;
import com.example.demo.service.StaffService;
import com.example.demo.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjy
 * @since 2025-05-25
 */
@RestController
@RequestMapping("/staff")
@Api(tags="员工管理")
public class StaffController {
    @Autowired
    private StaffService staffService;

    @GetMapping("/queryStaff")
    @ApiOperation("查询员工")
    public ResultVO<IPage<Staff>> queryStaff(String account,String name,Integer state,Integer pageNum, Integer pageSize) throws Exception{
        return staffService.queryStaff(account,name,state,pageNum,pageSize);
    }

    @PostMapping("/staffLogin")
    @ApiOperation("员工登录接口")
    public ResultVO<Staff> staffLogin(@RequestBody Staff staff) {
        return staffService.staffLogin(staff);
    }
    @PostMapping("/updateStaffState")
    @ApiOperation("更新员工状态")
    public ResultVO<Staff> updateStaffState(Integer id,Integer state) throws Exception{
        return staffService.updateStaffState(id,state);
    }

    @PostMapping("/addStaff")
    @ApiOperation("新增员工")
    public ResultVO<Staff> addStaff(Staff staff) throws Exception{
        return staffService.addStaff(staff);
    }
}
